package org.adl.registry.website.rim;

import java.io.InputStream;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.xml.sax.helpers.DefaultHandler;

/**
 *
 * @author Jacob Marks - Joint ADL Co-Lab
 * @version 1.0
 * @license This software is licensed as open source software pursuant to the terms defined in the Joint ADL Co-Lab Open Source Software License.  Use of any part of this software constitutes acceptance of this license. The Joint ADL Co-Lab open source agreement is available at {@link http://adlregistry.adlnet.gov/source_license.html}.
 */
public class RimResponseHandler extends DefaultHandler
{
    /**
     * A temporary storage variable for storing the value identified during a SAX parsing event.
     */
    private String mTempValue;
    
    /**
     * 
     * @param iXml 
     * @param iXsl 
     * @throws javax.xml.transform.TransformerConfigurationException 
     * @throws javax.xml.transform.TransformerException 
     * @return 
     */
    public static void transform(InputStream iXml, InputStream iXsl, StreamResult iResult)
    throws TransformerConfigurationException, TransformerException
    {
        // JAXP reads data using the Source interface
        StreamSource xmlSource = new StreamSource(iXml);
        StreamSource xsltSource = new StreamSource(iXsl);
        
        // the factory pattern supports different XSLT processors
        TransformerFactory transFact = TransformerFactory.newInstance();
        
        Transformer trans = transFact.newTransformer(xsltSource);
        
        trans.transform(xmlSource, iResult);
    }

    protected String getTempValue()
    {
        return mTempValue;
    }

    protected void setTempValue(String mTempValue)
    {
        this.mTempValue = mTempValue;
    }
}
